home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Users Group Library 1996 July / C-C++ Users Group Library July 1996.iso / vol_300 / 352_01 / strppsld.cpp < prev    next >
C/C++ Source or Header  |  1991-04-28  |  679b  |  23 lines

  1. // STRPPSLD.CPP
  2. //        contains String::slide.
  3. //        routine to 'slide' portion of a string from right to left.
  4. //        input string:    abcdefghi0
  5. //            positions:   0123456789        n =9 letters in string.
  6. //     cut ( 2, 5 ):     abghi0            position 6 moved right to position 3
  7. //                                        new length n=5.
  8. #include <stdlib.h>
  9. #include <string.h>
  10. #include "dblib.h"
  11.  
  12. void String::slide ( int start, int stop )
  13.     {
  14.     char *ss = s;   
  15.     int  sn = n;
  16.     if ( ss == NULL || sn ==0 ) return;
  17.     
  18.     memmove ( ss+start, ss+ stop+1, sn-stop );        // also moves terminal /0
  19.     if ( 0 >= (n = sn - stop + start -1) )
  20.         destruct();
  21.     }
  22.     
  23. //------------------ end STRPPSLD.CPP --------------------